<? 
	$title="User List"; 
	$pageid="4";
	$accessid=",a10,";

	
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
	//checkAccess("allow_gift_management",1);
?>

<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?

		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;
			case 2:
				$msg="<div class='dw_failed'>Voucher code already exist,update failed!</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	

	

	
	
	
		
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
<tr>
<script src="required/js/jquery-1.4.2.js" type="text/javascript"></script>
<script src="required/js/blockui.js" type="text/javascript"></script>
<script >
		function submitFrm()
		{
			$.blockUI({ message: '<h1><img src="images/loading.gif" /> Sending email, Just a moment...</h1>' });
			document.frm1.submit();
		}

		function frmValidate(frm1)
		{
			if(document.frm1.email_subject.value=="")
			{
				alert("please enter email subject or title");
				return false;
			}
			
		
			
			return true;
		}
		
		function checkExist(field,divName,showName) {
			var value = document.getElementById(field).value;
			if(value!=""){
				
				changeContent('required/js/checkVoucherExist.php?field='+field+'&value='+value+'&showName='+showName,divName)
			}
		}
	</script>
	<td valign="top">
			
            
			<form action="email_compose2.php" method="post" name="frm1" onsubmit="return frmValidate(this)">
            <script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
            <script type="text/javascript" src="required/js/calendarDateInput.js"></script>
			<table width="100%">
			
				<tr>
					<td colspan="3" class="title">
					<strong>Compose Email</strong>					
					</td>
				</tr>
               <Tr>
               		<td colspan="3">
                   
                    <div id="divMsg"><?= $msg ?></div>
                    </td>
               </Tr>
              	
             
				   
                
                 <tr>
                   <Td>Email Subject</Td><td><input type="text" value="" name="email_subject" size="50"   /></td>
                 </tr>
                
                 <tr valign="top">
                 	<Td>Send To</Td>
                    <Td>
                    	<select name="send_to[]" multiple="multiple">
                        	<option value="1">Active Subscriber</option>
                            <option value="2">Inactive Subscriber</option>
                            <option value="3">Active Member</option>
                            <option value="4">Inactive Member</option>
                        </select>
                    </Td>
                 </tr>
             
                <tr>
                    <td colspan="2" class="sub_title_line" ><br />Email Content</td>
                </tr>
                 <tr valign="top">
                 	<Td>Use the keyword to replace the data in email's subject and content</Td>
                    <td> 
                    <table class="solidborder" width="400">
                        <tr class="table_header">
                            <td>Keyword</td><td>To replace </td>
                        </tr>
                        <tr>
                            <td>[%firstname%]</td><td>Subscriber's first name</td>
                        </tr>
                         <tr>
                            <td>[%lastname%]</td><td>Subscriber's last name</td>
                        </tr>
                       <tr>
                            <td>[%email%]</td><td>Subscriber's email</td>
                        </tr>
                        
                     </table>
                     
                     </td>
                 </tr>    
                 <tr valign="top">
                    <td>Email Content</td>  
                    <td width="82%" valign="top">
                    			<?
									$get_info=mysql_query("select * from os_contactinfo where id=1");
									$i=mysql_fetch_array($get_info,MYSQL_ASSOC);
									$websitename_eng=$i['website_name'];
									$from_email=$i['email'];
									$os_url=$i['website'];
									
									$content="<br><br><br><br><br><br><br><br><br><br><br><br><a href=$os_url/os_unsubscribe.php?email=[%email%]>Click here</a> if you wish to unsubscribe."
								?>
                                <? include_once("fckeditor/fckeditor.php") ?>
                                <?php
                                    $oFCKeditor = new FCKeditor('email_content') ;
                                    $oFCKeditor->ToolbarSet = 'DeswinBasic';
                                    $oFCKeditor->BasePath = './fckeditor/' ;
                                    $oFCKeditor->Value = "$content" ;
                                    $oFCKeditor->Create() ;
                                ?>             </td>
              </tr>
                
				
				
			
				<td width="18%">
                
				  <input type="submit" value="Send" class="button" name="btnsubmit" onclick="submitFrm()">
                  <input type="button" value="Back" class="button" name="btnsubmit" onclick="window.open('email_compose2.php','_self')">
				</td>
			</table>
			</form>
		</td>
	</tr>
	
	
</table>
<? require("required/footer.php"); ?>

